﻿using Restaurant.entity;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Restaurant
{
    public partial class adjustfrm : Form
    {
        public adjustfrm()
        {
            InitializeComponent();
        }

        private void adjustfrm_Load(object sender, EventArgs e)
        {
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.Left = 0;
            this.Top = 0;
            int ct = SData.db.MDB.Count();
            for (int i = 0; i < ct; i++)
            {
                listBox1.Items.Add(SData.db.MDB[i].get_itemName());
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            itemname.Text = SData.db.MDB[listBox1.SelectedIndex].get_itemName();
            itemnum.Text = SData.db.MDB[listBox1.SelectedIndex].get_itemNum().ToString();
            itemprice.Text = SData.db.MDB[listBox1.SelectedIndex].get_itemPrice().ToString();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Multiselect = true;//该值确定是否可以选择多个文件
            dialog.Title = "请选择图片";
            dialog.Filter = "所有文件(*.*)|*.*";
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string file = dialog.FileName;
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Multiselect = true;//该值确定是否可以选择多个文件
            dialog.Title = "请选择图片";
            dialog.Filter = "所有文件(*.*)|*.*";
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string file = dialog.FileName;
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            Menuitem m = new Menuitem(nametxt.Text,Convert.ToInt32(numtxt.Text),Convert.ToDouble(pricetxt.Text));
            SData.db.MDB.Add(m);
            listBox1.Items.Add(m.get_itemName());
        }
    }
}
